const children = [

];
const routes = [
    //访问路由“/”,自动重定向到"/home"
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/test',
        name: 'Test',
        component: () => import('@/views/test.vue')
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import('@/views/login.vue')
    },
    {
        path: '/register',
        name: 'Register',
        component: () => import('@/views/register.vue')
    },
   
    {
        path: '/home',
        name: 'Home',
        component: () => import('@/views/home/home.vue'),
        children: [{
            path: '/home/index',
            name: 'Index',
            component: () =>
                import('@/views/home/index.vue')
        },
        {
            path: '/home/integral_trading',
            name: 'integral_trading',
            component: () =>
                import('@/views/home/integral_trading.vue')
        },
        {
            path: '/home/detail',
            name: 'detail',
            component: () => import('@/views/home/detail.vue')
        },
        {
            path: '/home/news',
            name: 'news',
            component: () => import('@/views/home/news.vue')
        },
        {
            path: '/home/project',
            name: 'Project',
            component: () => import('@/views/home/project.vue')
        },
        {
            path: '/home/myProject',
            name: 'myProject',
            component: () => import('@/views/home/myProject.vue')
        },
        {
            path: '/home/myDetail',
            name: 'myDetail',
            component: () => import('@/views/home/myDetail.vue')
        },
        {
            path: '/home/industryWeek',
            name: 'industryWeek',
            component: () =>
                import('@/views/home/industryWeek.vue')
        },
        ]
    },
    {
        path: '/404',
        name: "NotFound",
        component: () => import('@/views/404.vue')
    }

];

export const existsRoute = (path) => {
    for (let i = 0; i < routes.length; i++) {
        const r = routes[i];
        if (r.path == path) {
            return true;
        }
        if (r.children && r.children.length) {
            for (let k = 0; k < r.children.length; k++) {
                const sr = r.children[k];
                if (sr.path == path) {
                    return true;
                }
            }
        }
    }
    return false;
};

export default routes;